<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .test {
      width: 500px;
      height: 300px;
      background-color: grey;
      position: relative;
      margin: 0 auto;
      top: 100px;
    }
  </style>
</head>

<body>
  <div class="test"></div>

  <script>
    let dataStr = 'code=123&id=welnee&'
    dataStr = dataStr.slice(0, dataStr.length - 1)
    console.log(dataStr);
  </script>
</body>

</html>